﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>会员管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link href="/lobsteruiframe/layuiadmin/layui/css/layui.css" rel="stylesheet" />
    <link href="/lobsteruiframe/layuiadmin/style/admin.css" rel="stylesheet" />
    <script src="/lobsteruiframe/layuiadmin/layui/layui.js"></script>
    <script src="/jslib/jquery-3.4.1.min.js"></script>
    <script src="/jslib/lobster.js"></script>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                <div class="layui-input-inline">
                    <div class="layui-form-item">
                        <label class="layui-form-label">检索：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="searchStr" placeholder="请输入名称/手机号码" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-input-inline">
                    <div class="layui-form-item">
                        <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-user-front-search" id="btnSearch">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
                        </button>
                    </div>
                </div>
            </div>
            <div class="layui-card-body">
                <table id="UserInfoTable" lay-filter="UserInfoTable"></table>
            </div>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
    lobsterlayui.main(['index', 'layer', 'form', 'element'], {
        data: {
            $layui: null,
            right: null,
            tableuser: null,
        },
        pageload: function (right) {
            this.data.right = right;
            this.data.tableuser = this.loadtableuser();
            this.initevent();
        },
        initevent() {
            var self = this;
            var form = layui.form;
            var table = layui.table;

            //监听行工具事件
            table.on('tool(UserInfoTable)', function (obj) {
                var data = obj.data;//当前行数据

                //启用、停用
                if (obj.event === "disable" || obj.event === "enable") {
                    self.stopuser(data);
                }

            });

            //查找reload,通过条件，查询网格的table重载数据显示到界面
            form.on("submit(LAY-user-front-search)", function (data) {
                self.data.tableuser.reload({
                    where: {
                        searchStr: data.field.searchStr
                    },
                    page: {
                        curr: 1
                    }
                });
            });
        },
        loadtableuser() {
            var table = layui.table;
            return table.render({
                elem: '#UserInfoTable',
                headers: lobsterlayui.GetHeaderData(),
                where: {
                    searchStr: ''
                },
                height: 'full-120',
                cellMinWidth: 80,
                //size: 'sm',
                toolbar: '#toolbar',
                url: '/admin/v1/cuser/GetMPUserData',
                page: true,
                //even: true,
                cols: [[
                    { width: "120", field: 'MPUserId', title: '用户ID', fixed: 'left' },
                    { width: "120", field: 'MobileNo', title: '手机号码', fixed: 'left'},
                    { width: "150", field: 'UserName', title: '姓名' },
                    { width: "150", field: 'Nickname', title: '昵称' },
                    { width: "100", field: 'StrSex', title: '性别' },
                    { width: "180", field: 'UserBirthday', title: '生日', align: 'center' },
                    { width: "180", field: 'RegTime', title: '注册时间', align: 'center' },
                    { width: "120", field: 'StrDelFlag', title: '状态标识', sort: true, align: 'center', templet: '#flagTpl' },
                    { width: "100", title: '操作', fixed: 'right', align: 'center', toolbar: '#useroption' }   //操作script的id
                ]],
                parseData: function (res) {
                    return {
                        code: res.code,
                        msg: res.msg,
                        count: res.data.count,
                        data: res.data.data
                    }
                }
            });
        },
        stopuser(data) {
            var self = this;
            // 启用停用用户
            var confirm_msg = "";
            var status = 0;
            if (data.DelFlag == 0) {
                confirm_msg = "确认停用么?";
                status = 1;
            }
            else {
                confirm_msg = "确认启用么?";
                status = 0;
            }

            layer.confirm(confirm_msg, { icon: 3, title: "提示" },
                function (index) {

                    lobsterlayui.GET('/admin/v1/cuser/StopUser', { MPUserId: data.MPUserId, DelFlag: status }).then(data => {
                        layer.close(index); //关闭弹层
                        self.data.tableuser.reload();
                    })
                });
        },
    });

    /**
    * 关键信息隐藏
    * param str 字符串
    * param frontLen 字符串前面保留位数
    * param endLen 字符串后面保留位数
    * returns {string}
    */
    function hideCode(str, frontLen, endLen) {
        var len = str.length - frontLen - endLen;
        var xing = '';
        for (var i = 0; i < len; i++) {
            xing += '*';
        }
        return str.substring(0, frontLen) + xing + str.substring(str.length - endLen);
    }
</script>


<script type="text/html" id="flagTpl">
    {{#  if(d.DelFlag == '1'){ }}
    <span style="color:red;">{{ d.StrDelFlag }}</span>
    {{#  } else { }}
    {{ d.StrDelFlag }}
    {{#  } }}
</script>
<script type="text/html" id="TelephoneTpl">
    
</script>
<script type="text/html" id="useroption">
    {{#  if(d.DelFlag == '0'){ }}
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="disable"><i class="layui-icon layui-extend-stop"></i>停用</a>
    {{#  } else { }}
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="enable"><i class="layui-icon layui-icon-ok"></i>启用</a>
    {{#  } }}
</script>